package org.tsinghua.answer.domain.user;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

public interface UserRepository extends CrudRepository<User, String> {

	User findByUsernameOrEmail(String username, String email);
	
	User findByUsername(String username);
	
	User findByEmail(String email);
	
	@Query("select u from User u where u.type = 'VOLUNTEER'"
			+ " and (u.nickname like :keyword or u.username like :keyword)"
			+ " order by nickname, username")
	Page<User> volunteers(@Param("keyword") String keyword, Pageable pageable);
}
